import Opt from '@/components/dt/info/Opt.js'

class Column extends Opt {

  constructor() {
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [{
      type: 'index',
      title: '序号',
      minWidth: 50,
    },
    {
      field: 'bonusName',
      title: '奖金单名称',
      minWidth: 200
    },
    {
      field: 'bonusType',
      title: '奖金单类型',
      minWidth: 110,
      cell: {
        text: {
          type: 'dict',
          key: 'bonusType'
        }
      }
    },
    {
      field: 'roomNum',
      title: '结算房源套数',
      minWidth: 110
    },
    {
      field: 'settlementSumAmount',
      title: '可结算房源总销(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    },
    {
      field: 'sumAgentCost',
      title: '可结算代理费(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    },
    {
      field: 'bonusAmount',
      title: '奖金总额(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    },
    {
      field: 'bonusMonth',
      title: '奖金单月份',
      minWidth: 100,
    },
    {
      field: 'createTime',
      title: '创建日期',
      minWidth: 130,
      cell: {
        text: {
          type: 'date'
        }
      }
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 90,
      cell: (item) => {
        return {
          text: {
            type: 'dict',
            key: 'bonusAwardStatus',
            color: item.status == 'NO_PASS' ? 'red' : null
          }
        }
      }
    },
    {
      field: 'nextReviewer',
      title: '当前审批节点',
      minWidth: 140,
    },
    {
      title: '操作',
      width: 230,
      fixed: 'right',
      cell: (item) => {
        let type = item.bonusType
        return {
          btn: [{
            title: '查看',
            event: 'onDetail',
            code: '0112010600',
            visible: item.status != 'UNSUBSTITUTED'
          }, {
            title: '编辑',
            event: 'onEdit',
            code: '0112010200',
            visible: item.status == 'UNSUBSTITUTED'
          }, {
            title: '重新提交',
            event: 'onResend',
            code: '0112010500',
            visible: item.status == 'NO_PASS' || item.status == 'WITHDRAWN'
          }, {
            title: '撤回',
            event: 'onRecall',
            code: '0112010400',
            visible: item.status == 'APPROVAL'
          }, {
            title: '流程信息',
            event: 'onFlow',
            visible: item.status != 'UNSUBSTITUTED'
          }, {
            title: '重新计算',
            event: 'onRecalculate',
            code: '0112010800',
            visible: item.status == 'UNSUBSTITUTED' && (type == 'STANDARD' || type == 'PRE' || type == 'DEPOSIT' || type == 'SKIP_POINT')
          }, {
            title: '删除',
            event: 'onDelete',
            code: '0112010300',
            visible: item.status == 'UNSUBSTITUTED' || item.status == 'NO_PASS' || item.status == 'WITHDRAWN'
          }]
        }
      }
    }]
  }

}

export default Column